package com.lbsq.user.dao.mybatis;

import java.util.List;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
import com.lbsq.user.dao.UserDao;
import com.lbsq.user.pojo.User;

public class MyBatisUserDao extends SqlMapClientDaoSupport implements UserDao {

	public List<User> selectUserList()
    {
        return this.getSqlMapClientTemplate().queryForList("User.selectAllUser");
    }

	public User selectUserByID(Long id) {
		List<User> list = this.getSqlMapClientTemplate().queryForList("User.selectUserByID", id);
		return list.get(0);
	}
	
	public User selectUserByName(String name) {
		List<User> list = this.getSqlMapClientTemplate().queryForList(
				"User.selectUserByName", name);
		return list.size() == 0 ? null : list.get(0);
	}

	public User checkUser(final User user) {
		User u = (User) this.getSqlMapClientTemplate().queryForObject("User.checkUser",user);
		return user;
	}

}
